package mil.af.amc.adpetracker.dao.hibernate;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.dao.DataAccessException;
import mil.af.amc.adpetracker.dao.Dao;
import mil.af.amc.adpetracker.dao.exceptions.DaoException;

/**
 * Created by IntelliJ IDEA.
 * User: schevus.osborne
 * Date: Feb 1, 2007
 * Time: 1:04:51 PM
 * To change this template use File | Settings | File Templates.
 */
public class AbstractHibernateDao extends HibernateDaoSupport implements Dao {

    public void save(Object object) throws DaoException {
        try {
            getHibernateTemplate().saveOrUpdate(object);
        } catch (DataAccessException e) {
            throw new DaoException("errors.dao.object-could-not-be-saved", e);
        }
    }

    public void delete(Object object) throws DaoException {
        try {
            getHibernateTemplate().delete(object);
        } catch (DataAccessException e) {
            throw new DaoException("errors.dao.object-could-not-be-deleted");
        }
    }
}
